﻿<Application x:Class="SPIWareMVVM.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="Views/Window1.xaml">
    <Application.Resources>
        <Style
            x:Key="textBoxInErrorStyle"
            TargetType="{x:Type TextBox}" >
            <Style.Triggers>
                <!-- A Property Trigger that sets the value of the  -->
                <!-- Tooltip to the error message, when the binding -->
                <!-- has a validation error.                        -->
                <Trigger
                    Property="Validation.HasError"
                    Value="true">
                    <Setter
                        Property="ToolTip"
                        Value="{Binding
                                RelativeSource={x:Static
                                                  RelativeSource.Self},
                                Path=(Validation.Errors)[0].ErrorContent}"/>
                </Trigger>
            </Style.Triggers>
            <Setter
                Property="Validation.ErrorTemplate">
                <Setter.Value>
                    <ControlTemplate>
                        <DockPanel DockPanel.Dock="Right">
                            <AdornedElementPlaceholder/>
                            <Image
                               Source="Error.png"
                               Width="16"
                               Height="16"
                               ToolTip="{Binding
                                         Path=AdornedElement.ToolTip,
                                         RelativeSource={RelativeSource
                                            Mode=FindAncestor,
                                            AncestorType={x:Type Adorner}}}"/>
                        </DockPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>
</Application>
